package com.bestescortbedsystem.controller;

import com.bestescortbedsystem.entity.*;
import com.bestescortbedsystem.service.XiaoShouService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: LuXi
 * @Date: 2021/3/3 16:33
 * @Description:
 */
@Api(value = "销售报表模块")
@RestController
@RequestMapping("baobiao")
public class BaoBiaoController {
    @Resource
    private XiaoShouService xiaoShouService;

    @RequestMapping("xiaoshou")
    @ApiOperation(value = "获取所有销售信息", notes = "获取所有销售信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "xiaoShouSearch",value = "查询条件",required = false,dataTypeClass = XiaoShouSearch.class),
            @ApiImplicitParam(name = "pageNum",value = "当前页码",required = true,dataTypeClass = Integer.class)
    })
    public Map<String,Object> list(XiaoShouSearch xiaoShouSearch, @RequestParam(defaultValue = "1")Integer pageNum){
        Map<String,Object> map = new HashMap<>();
        try{
            Map<String, Object> all = xiaoShouService.getXiaoShou(xiaoShouSearch,pageNum);
            map.put("result",true);
            map.put("map",all);
        }catch (Exception e){
            map.put("result",false);
        }finally {
            return map;
        }
    }

    @RequestMapping("kuaiji")
    @ApiOperation(value = "获取所有会计信息", notes = "获取所有会计信息")
    @ApiImplicitParam(name = "pageNum",value = "当前页码",required = true,dataTypeClass = Integer.class)
    public Map<String,Object> kuaiji(@RequestParam(defaultValue = "1")Integer pageNum){
        Map<String,Object> map = new HashMap<>();
        try{
            Map<String, Object> all = xiaoShouService.getKuaiji(pageNum);
            map.put("map",all);
            map.put("result",true);
        }catch (Exception e){
            map.put("result",false);
        }finally {
            return map;
        }
    }
}
